<script setup lang="ts">
import useSetting from '@renderer/composables/useSetting'
import { reactive } from 'vue'
import { Action, ElMessageBox } from 'element-plus'
const lossList = reactive([
  {
    title: '基础项目',
    checkInfo: [
      {
        name: '套内面积计算系数',
        key: 'tnmj_loss',
      },
      {
        name: '墙漆面积计算系数',
        key: 'qqmj_loss',
      },
      {
        name: '地暖面积计算系数',
        key: 'dnmj_loss',
      },
      {
        name: '电路按米计算系数',
        key: 'dlmi_loss',
      },
      {
        name: '水路按米计算系数',
        key: 'slmi_loss',
      },
      {
        name: '铝扣板面积计算系数',
        key: 'buckle_plate_loss',
      },
    ],
  },
  {
    title: '水电暖材料',
    checkInfo: [
      {
        name: '1.5平方电线损耗系数',
        key: 'one_square',
      },
      {
        name: '2.5平方电线损耗系数',
        key: 'two_square',
      },
      {
        name: '4平方电线损耗系数',
        key: 'three_square',
      },
      {
        name: '红色线管损耗系数',
        key: 'red_pipe_loss',
      },
      {
        name: '蓝色线管损耗系数',
        key: 'blue_pipe_loss',
      },
      {
        name: '红色线管直接损耗系数',
        key: 'red_pipe_in_loss',
      },
      {
        name: '蓝色线管直接损耗系数',
        key: 'blue_pipe_in_loss',
      },
      {
        name: '锁母损耗系数',
        key: 'suomu_loss',
      },
      {
        name: '线盒损耗系数',
        key: 'xianhe_loss',
      },
      {
        name: '八角盒损耗系数',
        key: 'bajiaohe_loss',
      },
      {
        name: '波纹管损耗系数',
        key: 'bowenguan_loss',
      },
      {
        name: '水管损耗系数',
        key: 'water_pipe_loss',
      },
      {
        name: '三通损耗系数',
        key: 'santong_loss',
      },
      {
        name: '直接损耗系数',
        key: 'zhijie_loss',
      },
      {
        name: '过桥损耗系数',
        key: 'guoqiao_loss',
      },
      {
        name: '弯头损耗系数',
        key: 'wantou_loss',
      },
      {
        name: '堵头损耗系数',
        key: 'dutou_loss',
      },
      {
        name: '管卡（吊卡）损耗系数',
        key: 'guanka_loss',
      },
      {
        name: '水路保温管损耗系数',
        key: 'waterway_loss',
      },
    ],
  },
  {
    title: '瓦工材料',
    checkInfo: [
      {
        name: '墙砖损耗系数',
        key: 'wall_loss',
      },
      {
        name: '地砖损耗系数',
        key: 'floor_loss',
      },
      {
        name: '卫生间地砖损耗系数',
        key: 'mini_floor_loss',
      },
      {
        name: '踢脚线损耗系数',
        key: 'skirting_line_loss',
      },
      {
        name: '沙子损耗系数',
        key: 'sand_loss',
      },
      {
        name: '水泥损耗系数',
        key: 'cement_loss',
      },
      {
        name: '背胶损耗系数',
        key: 'adhesive_loss',
      },
    ],
  },
  {
    title: '木工材料',
    checkInfo: [
      {
        name: '石膏板损耗系数',
        key: 'gypsum_board_loss',
      },
      {
        name: '欧松板损耗系数',
        key: 'osb_board_loss',
      },
      {
        name: '木方损耗系数',
        key: 'batten_loss',
      },
      {
        name: '主龙骨损耗系数',
        key: 'main_keel_loss',
      },
      {
        name: '副龙骨损耗系数',
        key: 'second_keel_loss',
      },
      {
        name: '边龙骨损耗系数',
        key: 'line_keel_loss',
      },
      {
        name: '吊丝损耗系数',
        key: 'hang_spring_loss',
      },
      {
        name: '胀头胀管损耗系数',
        key: 'zhangtou_loss',
      },
      {
        name: '膨胀丝损耗系数',
        key: 'pengzhangsi_loss',
      },
      {
        name: '38钢排损耗系数',
        key: 'gangpai38_loss',
      },
      {
        name: '32钢排损耗系数',
        key: 'gangpai32_loss',
      },
      {
        name: '25钢排损耗系数',
        key: 'gangpai25_loss',
      },
      {
        name: '2.5自攻丝损耗系数',
        key: 'zigongsi_loss',
      },
      {
        name: '30直钉损耗系数',
        key: 'zhiding30_loss',
      },
      {
        name: '25直钉损耗系数',
        key: 'zhiding25_loss',
      },
      {
        name: '白乳胶损耗系数',
        key: 'bairujiao_loss',
      },
      {
        name: '木工发泡胶损耗系数',
        key: 'mgfpj_loss',
      },
    ],
  },
  {
    title: '墙漆材料',
    checkInfo: [
      {
        name: '面漆损耗系数',
        key: 'finish_loss',
      },
      {
        name: '腻子粉损耗系数',
        key: 'putty_powder_loss',
      },
      {
        name: '嵌缝石膏粉损耗系数',
        key: 'caulking_gypsum_loss',
      },
      {
        name: '找平石膏粉损耗系数',
        key: 'painting_gypsum_loss',
      },
      {
        name: '阴角损耗系数',
        key: 'inside_corner_loss',
      },
      {
        name: '阳角损耗系数',
        key: 'outer_corner_loss',
      },
      {
        name: '1.1保护膜损耗系数',
        key: 'mo11_loss',
      },
      {
        name: '2.4保护膜损耗系数',
        key: 'mo24_loss',
      },
      {
        name: '接缝带损耗系数',
        key: 'jiefengdai_loss',
      },
    ],
  },
  {
    title: '木地板材料',
    checkInfo: [
      {
        name: '木地板损耗系数',
        key: 'wood_floor_loss',
      },
      {
        name: '防潮膜损耗系数',
        key: 'fangchaomo_loss',
      },
      {
        name: '扣条损耗系数',
        key: 'koutiao_loss',
      },
    ],
  },
  {
    title: '其他材料',
    checkInfo: [
      {
        name: '石膏线损耗系数',
        key: 'gypsum_line_loss',
      },
      {
        name: '装门发泡胶损耗系数',
        key: 'zmfpj_loss',
      },
      {
        name: '瓷砖背景结构胶损耗系数',
        key: 'jiegoujiao_loss',
      },
      {
        name: '瓷砖背景云石胶损耗系数',
        key: 'yunshijiao_loss',
      },
    ],
  },
])
const handleSave = async () => {
  ElMessageBox.alert('本次修改数据，只对新创建的“模板/预算”生效。', '温馨提示', {
    showCancelButton: true,
    callback: async (action: Action) => {
      if (action == 'confirm') {
        await setLossRate()
      }
    },
  })
}
const { getLossRate, lossInfo, setLossRate } = useSetting()
await getLossRate()
</script>

<template>
  <main class="bg-white flex flex-col justify-between rounded-md" v-if="lossInfo">
    <el-form label-width="auto">
      <div class="overflow-y-auto flex flex-col overflow-x-hidden">
        <div class="flex flex-col gap-3" v-for="(item, index) in lossList" :key="index">
          <text class="text-xl text-black font-bold">{{ item.title }}</text>
          <el-row :gutter="10">
            <el-col v-for="(checkItem, checkIndex) in item.checkInfo" :key="checkIndex" :span="8">
              <el-form-item :label="checkItem.name + ':'">
                <el-input v-model="lossInfo[checkItem.key]" type="number" @mousewheel.native.prevent placeholder="请输入" />
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </div>
      <!--  -->
    </el-form>
    <div class="flex justify-center">
      <button class="save-button" @click="handleSave">保存设置</button>
    </div>
  </main>
</template>

<style lang="scss" scoped>
.save-button {
  @apply text-white px-16 py-3 rounded-md;
  background: linear-gradient(142deg, #ff9600 0%, #ffb242 100%);
}
</style>
